@extends('admin.layout.layout')
@section('title','板块列表')
@section('con')
<div id="page-wrapper" style="min-height: 349px;">
            <div class="row">
                <div class="col-lg-12">
                    <h1 class="page-header">板块列表 <font size="5">--- {{$blocks[0]->sname}}</font> </h1>
                </div>
                <!-- /.col-lg-12 -->
            </div>
            <!-- /.row -->
            <div class="row">
                <div class="col-lg-12">
                    <div class="panel panel-default">
                        <div class="panel-heading">
                            板块列表
                        </div>
                        <!-- /.panel-heading -->
                        <div class="panel-body">
                            <div class="dataTable_wrapper">
                                <div id="dataTables-example_wrapper" class="dataTables_wrapper form-inline dt-bootstrap no-footer">
                                <div class="row">
                                <form action="{{url('/admin/user/index')}}">
	                                
                                </div>
                                 </form>
                                <div class="row">
                                	<div class="col-sm-12">
                                		<table class="table table-striped table-bordered table-hover dataTable no-footer" id="dataTables-example" role="grid" aria-describedby="dataTables-example_info">
                                    		<thead>
                                    			<tr>
		                                    		<th>Id号</th>
		                                    		<th>板块名</th>
		                                    		<th>帖子数</th>
                                                    <th>版主id</th>
		                                    		<th>版主名字</th>
                                                    <th>板块介绍</th>
		                                    		<th>板块公告</th>
		                                    		<th>操作</th>
                                    			</tr>
                                    		</thead>
                                    	<tbody>
                                    	@foreach($blocks as $k=>$v)
		                                    <tr class="gradeA odd" role="row">
		                                        <td class="sorting_1">{{$v->bid}}</td>
		                                        <td class="sorting_2">{{$v->bname}}</td>
		                                        <td class="sorting_3">{{$v->bnum}}</td>
                                                <td class="center">{{$v->buid}}</td>
		                                        <td class="center">{{$v->username}}</td>
                                                <td class="center" style="width:250px; overflow:hidden; text-overflow:ellipsis;overflow-wrap:bread-word;" >{{$v->bintro}}</td>
		                                        <td class="center" style="width:250px;overflow:hidden; text-overflow:ellipsis; overflow-wrap:bread-word;">{{$v->binfo}}</td>
		                                        <td class="center">
		                                        	<button class="btn btn-danger btn-sm delete-btn" type="button">
                              						  删除
                           							</button>
                           							<a href="{{url('/admin/block/edit',['id'=>$v->bid])}}" class="btn btn-sm  btn-success">修改</a>
                          
		                                        </td>
		                                    </tr>
		                                @endforeach 
                                    	</tbody>
                                </table>
                                </div>
                                </div>
                                <div class="row">
                                </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
@endsection
@section('js')
<script type="text/javascript">     
    $.ajaxSetup({
        headers:{
            'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
        }
    });


    //绑定单击事件
    $('.delete-btn').click(function(){
        var id = $(this).parents('tr').find('.sorting_1').html();
        var btn = $(this);

        //发送ajax请求
        $.post('/admin/block/delete',{bid:id},function(data){
            if (data == 0) {
                //删除成功
                alert('删除成功');
                btn.parents('tr').remove();
            }else{
                //删除失败
                alert('删除失败');
            }
        })
    });
</script>
@endsection